package edu.kit.los.event;

import java.util.Date;

/**
 * @author felix Vereinheitlicht die verschiedenen Events, um sie standartisiert
 *         weiterverarbeiten und anzeigen zu können.
 */
public class StandartEvent implements edu.kit.los.event.EventPrototype {

	private double geoLat;
	private double geoLong;
	private Date start_time;
	private Date end_time;
	private String url;
	private String name;
	private String description;
	private String location;

	/**
	 * Konstruktor, um aus einem FacebookEvent ein StandartEvent zu konstruiern
	 * 
	 * @param FacebookEvent fbe
	 */
	public StandartEvent(FacebookEvent fbe) {
		this.name = fbe.getName();
		this.description = fbe.getDescription();
		this.geoLat = fbe.getGeoLat();
		this.geoLong = fbe.getGeoLong();
		this.location = fbe.getLocation();
		this.start_time = fbe.getStart_time();
		this.end_time = fbe.getEnd_time();
		this.url = fbe.getURL();
	}

	/**
	 * Konstruktor, um aus einem EventFul-Event ein StandartEvent zu konstruiern
	 * @param EventFulEvent event
	 */
	public StandartEvent(com.evdb.javaapi.data.Event event) {
		this.name = event.getTitle();
		this.description = event.getDescription();
		this.geoLat = event.getVenueLatitude();
		this.geoLong = event.getVenueLongitude();
		this.location = event.getVenueAddress();
		this.start_time = event.getStartTime();
		this.end_time = event.getStartTime();
		this.url = null;
		// this.url = event.getTrackbacks().get(0).getUrl(); //TODO URl
		// rausfinden
		// ID Beispiele: E0-001-042411977-2, V0-001-000529109-5
	}

	/**
	 * Konstruktor, um aus einem UpcomingEvent ein StandartEvent zu konstruiern
	 * @param UpcomingEvent event
	 */
	public StandartEvent(upcoming.client.Event event) {
		this.name = event.getName();
		this.description = event.getDescription();
		this.geoLat = Double.parseDouble(event.getLatitude());
		this.geoLong = Double.parseDouble(event.getLongitude());
		this.location = event.getVenueAddress();
		this.start_time = null;
		this.end_time = null;
		// this.start_time = Date.parse(event.getStartTime()); //TODO Daten
		// parsen, URL rausfinden
		// this.end_time = Date.parse(event.getStartTime());
		this.url = event.getTicketUrl(); // TODO scheint machnmal zu
											// funktionieren, und manchmal auf
											// die eigene URL zurückzuleiten!!!
	}

	public String getDescription() {
		if (description == null)
			return "";
		try {
			return description;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "";
		}
	}

	public String getLocation() {
		if (location == null)
			return "";
		try {
			return location;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "";
		}
	}

	public double getGeoLat() {
		return geoLat;
	}

	public double getGeoLong() {
		return geoLong;
	}

	public Date getStart_time() {
		return start_time;
	}

	public Date getEnd_time() {
		return end_time;
	}

	public String getURL() {
		if (url == null)
			return "";
		try {
			return url;
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}

	public String getName() {
		if (name == null)
			return "";
		try {
			return name;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "";
		}
	}

	public void setGeoLat(double geoLat) {
		this.geoLat = geoLat;
	}

	public void setGeoLong(double geoLong) {
		this.geoLong = geoLong;
	}

	public void setStart_time(Date start_time) {
		this.start_time = start_time;
	}

	public void setEnd_time(Date end_time) {
		this.end_time = end_time;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setLocation(String location) {
		this.location = location;
	}

}
